package com.kangye.game.controller;

import com.alibaba.fastjson.JSON;
import com.kangye.game.pojo.TUser;
import com.kangye.game.service.AddTUserService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 当用户注册玩手机号跳到此控制器接口
 *
 * @program: game_orders
 * @description: 存储注册用户个人信息控制器
 * @author: lys
 * @create: 2021-09-01 20:09
 **/
@RestController
@CrossOrigin
public class StorageController {
    @Resource
    private AddTUserService addTUserService;

    @RequestMapping("/addTUser.action")
    public Object addTUser(String loginname, String password, String username, String tel, int sex) {
        System.out.println(loginname + "**" + password + "**" + tel);
        TUser tUser = new TUser();
        tUser.setLoginname(loginname);
        tUser.setPassword(password);
        tUser.setUsername(username);
        tUser.setTel(tel);
        tUser.setSex(sex);
        int i = addTUserService.addTUser(tUser);
        Map<String, String> map = new HashMap<>();
        if (i != 0) {
            String code = JSON.toJSONString("200");
            map.put("code", code);
        } else {
            String code = JSON.toJSONString("400");
            map.put("code", code);
        }
        return map;
    }

}
